package com.jyw.business.obstacles.domain.vo.wechat;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.jyw.business.obstacles.domain.vo.web.HomeMineServerVO;
import com.jyw.common.annotation.Conversion;
import com.jyw.common.constant.SysDictTypeConstant;
import com.jyw.common.core.domain.entity.SysUser;
import com.jyw.common.enums.ConversionType;
import com.jyw.system.utils.UserUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.FieldNameConstants;
import org.springframework.util.ObjectUtils;

import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

@ApiModel("微信工单日报统计实体")
@Data
@NoArgsConstructor
@FieldNameConstants
public class WxOrderDailyDetailVO {

    @ApiModelProperty("坐席人员")
    @Conversion(value = ConversionType.USER,name = Fields.userName)
    private String userId;

    @ApiModelProperty("坐席人员名称")
    private String userName;

    @ApiModelProperty("报修时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    @ApiModelProperty("报修科室")
    @Conversion(value = ConversionType.DEPT,name = Fields.deptName)
    private Long deptId;

    @ApiModelProperty("报修科室名称")
    private String deptName;

    @ApiModelProperty("报修人")
    private String user;

    @ApiModelProperty("报修人电话")
    private String phone;

    @ApiModelProperty("工单状态")
    @Conversion(value = ConversionType.DICT,dictType = SysDictTypeConstant.OBS_FAULT_TYPE)
    private String currState;

    @ApiModelProperty("工单状态标签")
    private String currStateToName;

    @ApiModelProperty("所找人员ID")
    @Conversion(value = ConversionType.USER,name = Fields.findUserName)
    private Long findUser;

    @ApiModelProperty("所找人员名称")
    private String findUserName;

    @ApiModelProperty("所找人员电话")
    private String findUserPhone;

    @ApiModelProperty("类型 1未接 2已接 3未建 4已建 5未派 6已派 7电话找人 8电话解决 9无效电话")
    private String type;

    public String getFindUserPhone() {
        if(!ObjectUtils.isEmpty(getFindUser())){
            SysUser user = UserUtils.getUserById(getFindUser());
            return user.getPhonenumber();
        }
        return this.findUserPhone;
    }
}
